<template>
  <div class="list">
     <div class="group_container">
      <div @click="groupList1" :class="{on:isShow_session}">会话列表</div>
      <div @click="groupList2" :class="{on:isShow_friends}">我的好友</div>
      <div @click="groupList3" :class="{on:isShow_group}">群组</div>
    </div>

    <div class="ul_container">
      <div>
        <div>
          <ul v-show="isShow_session" class="session_list">
            <li v-for="item in sessions">
              <img class="avatar" width="30" height="30" :alt="item.user.name" :src="item.user.img">
              <div class="name_new">
                <div class="name">{{item.user.name}}111</div>
                <div class="new">{{item.user.new}}</div>
              </div>
              <div class="time">{{item.user.time}}</div>
            </li>
          </ul>
          <ul v-show="isShow_friends" class="friends_list">
            <li v-for="item in sessions">
              <img class="avatar" width="30" height="30" :alt="item.user.name" :src="item.user.img">
              <div class="friends_name">{{item.user.name}}222 </div>
            </li>
          </ul>
          <ul v-show="isShow_group" class="group_list">
            <li v-for="item in sessions">
              <img class="avatar" width="30" height="30" :alt="item.user.name" :src="item.user.img">
              <div class="friends_name">{{item.user.name}}333 </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      isShow_session:true,
      isShow_friends:false,
      isShow_group:false,
      active:0,
      sessions: [
        {
          id: 1,
          user: {
            name: "示例介绍",
            img: "dist/images/1.jpg",
            new: "测试消息1",
            time: "12:58"
          },
          messages: []
        },
        {
          id: 2,
          user: {
            name: "webpack",
            img: "dist/images/2.jpg",
            new: "测试消息2",
            time: "昨天"
          },
          messages: []
        },
        {
          id: 3,
          user: {
            name: "vue",
            img: "dist/images/3.jpg",
            new: "测试消息3",
            time: "18/6/5"
          },
          messages: []
        },
        {
          id: 4,
          user: {
            name: "html5",
            img: "dist/images/3.jpg",
            new: "测试消息3",
            time: "18/6/5"
          },
          messages: []
        },
        {
          id: 5,
          user: {
            name: "css3",
            img: "dist/images/3.jpg",
            new: "测试消息3",
            time: "18/6/5"
          },
          messages: []
        },
        {
          id: 6,
          user: {
            name: "node",
            img: "dist/images/3.jpg",
            new: "测试消息3",
            time: "18/6/5"
          },
          messages: []
        },
        {
          id: 7,
          user: {
            name: "vue",
            img: "dist/images/3.jpg",
            new: "测试消息3",
            time: "18/6/5"
          },
          messages: []
        },
        {
          id: 8,
          user: {
            name: "vue",
            img: "dist/images/3.jpg",
            new: "测试消息3",
            time: "18/6/5"
          },
          messages: []
        },
        {
          id: 9,
          user: {
            name: "vue",
            img: "dist/images/3.jpg",
            new: "测试消息3",
            time: "18/6/5"
          },
          messages: []
        },
        {
          id: 10,
          user: {
            name: "vue",
            img: "dist/images/3.jpg",
            new: "测试消息3",
            time: "18/6/5"
          },
          messages: []
        },
        {
          id: 11,
          user: {
            name: "vue",
            img: "dist/images/3.jpg",
            new: "测试消息3",
            time: "18/6/5"
          },
          messages: []
        },
        {
          id: 12,
          user: {
            name: "vue",
            img: "dist/images/3.jpg",
            new: "测试消息3",
            time: "18/6/5"
          },
          messages: []
        }
      ]
    };
  },
  methods: {
   groupList1(){
      this.isShow_session = true
      this.isShow_friends = false
      this.isShow_group = false
   },
   groupList2(){
      this.isShow_session = false
      this.isShow_friends = true
      this.isShow_group = false
   },
   groupList3(){
      this.isShow_session = false
      this.isShow_friends = false
      this.isShow_group = true
   },
  }
};
</script>

<style scoped lang="scss">
.list {
  ul {
    list-style: none;
    padding: 0px 0px 0px 0px;
    margin: 0px 0px;
  }
  li {
    padding: 12px 0px 12px 12px;
    border-bottom: 1px solid #292c33;
    cursor: pointer;
    transition: background-color 0.1s;
    display: flex;
    justify-content: space-between;
    flex-direction: row;

    &:hover {
      background-color: rgba(255, 255, 255, 0.03);
    }
    &.active {
      background-color: rgba(255, 255, 255, 0.1);
    }
  }
  .avatar,
  .name {
    vertical-align: middle;
  }
  .avatar {
    border-radius: 2px;
    width: 38px;
    height: 38px;
  }
  .name_new {
    width: 146px;
  }
  .name_new > .name {
    font-size: 14px;
    line-height: 20px;
    width: 96%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .name_new > .new {
    font-size: 12px;
    color: #999;
    width: 96%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding-top: 3px;
  }
  .time {
    width: 40px;
    color: #b9b9b9;
    font-size: 12px;
    padding-right: 6px;
    line-height: 35px;
    text-align: right;
  }

  .group_container {
    display: flex;
    justify-content: space-between;
    width: 100%;
    height: 50px;
    line-height: 30px;
    padding: 10px 0px;
    border-bottom: 1px solid #24272c;
  }
  .group_container > div {
    width: 33.3%;
    text-align: center;
    font-size: 13px;
    cursor: pointer;
    color: #999;
  }
  .group_container > div.on {
    color: #fff;
    font-size: 14px;
  }
  .ul_container{
    // min-height: 445px;
    // max-height: 780px;
    // height: 100%;
    // min-height: 650px;
    width: 250px;
    overflow: hidden;
    position: absolute;
    height: calc(100% - (155px));
  }
  .ul_container>div{
    height: 100%;
    overflow: auto;
  }
  .ul_container>div>div{
    height: 100%;
  }

  .ul_container>div::-webkit-scrollbar {
    display: none;
  }
  .friends_name{
    width: 190px;
    padding-right: 20px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 14px;
    line-height: 38px;
  }
}
</style>